package utils;

import data.ClusteredNode;
import data.Gene;

public class Line {
	
	private String str="";
	
	@Override
	public boolean equals(Object obj) {
		return this.toString().equals(obj.toString());
	}

	private Gene[] genes;
	private ClusteredNode[] clusters;
	
	@Override
	public int hashCode() {
		return toString().hashCode();
	}
	
	public String toString() {
		return str;
	}
	
	private void initStr() {
		str="";
		if (genes != null) {
			str= genes[0].toString()+ " & " +genes[1].toString();
		}
		if (clusters != null) {
			str= clusters[0].toString()+ " & " +clusters[1].toString();
		}
	}

	public Line(Gene g1, Gene g2) {
		genes= new Gene[2] ;
		genes[0]=g1;
		genes[1]=g2;
		if (g1.getAverage()>g2.getAverage()) {
			genes[0]=g2;
			genes[1]=g1;
		}
		initStr();
	}

	public Line(ClusteredNode c1, ClusteredNode c2) {
		clusters= new ClusteredNode[2] ;
		clusters[0]=c1;
		clusters[1]=c2;
		initStr();
	}

	public Gene[] getGenes() {
		return genes;
	}

	public ClusteredNode[] getClusters() {
		return clusters;
	}

}
